
import java.io.Serializable;
import java.util.ArrayList;

class Request implements Serializable{

  //Request type
  private RequestType requestType;

  //Track object containing the parameters to be consulted
  private Track consult;

  //Download path in case the request is for a download
  private String location;

  //Visited nodes
  private ArrayList<String> visited;

  //In case it's a CONSULT the node must know how the client will reach him
  private String serverName;

  /**
   * Constructor
   * 
   * In case it's a consult.
   * 
   * @param consult  Track containing the consult information
   * @param visited  Nodes already visited in this request
   * @param serverName Name of the server that is being consulted
   */
  Request(Track consult, ArrayList<String> visited, String serverName){
    this.consult = consult;
    this.visited = visited;
    this.serverName = serverName;
  }

  /**
   * Constructor
   * 
   * In case it's a download, user may specify creator or title.
   * In either case he must specify the nodes already visited so
   * we make no cycles
   * 
   * @param location Location in the host of the track to be downloaded
   */
  Request(String location){
    this.location = location;
  }

  public RequestType getRequestType(){
    return requestType;
  }

  public Track getConsult(){
    return this.consult;
  }

  public String getLocation(){
    return location;
  }

  public ArrayList<String> getVisited(){
    return this.visited;
  }

  public String getServerName(){
    return serverName;
  }

  public void setServerName(String a){
      this.serverName = a;
  }

  public void setVisited(ArrayList<String> a){
    this.visited = a;
  }
  public String toString(){
    String s = "creator: " + consult.getCreator() + " title: " + consult.getTitle() + '\n';
    s += " serverName: " + serverName + "location: " + location;
    return s;
  }
}